<?php

    class x_alta {
        protected $db_man;
    	protected $select="select id_alta, clau, ip, dalta, dbaixa from x_alta";
    	protected $insert="insert into x_alta(clau, dalta, dbaixa) values('%s', now(), '%s')";
    	protected $delete="delete from x_alta where clau='%s'";
    	
        function x_alta($dbm) {
        	$this->db_man=$dbm;
        }
        
        function add_alta($clau, $dbaixa) {
        	return ($this->db_man->do_dml(sprintf($this->insert, $clau, $dbaixa)));
        }
        
        function delete_alta($clau) {
        	return ($this->db_man->do_dml(sprintf($this->delete, $clau)));
        }
        
        function get_altas() {
        	return ($this->db_man->do_query($this->select));
        }
        
        function is_valid_ip($ip) {
        	return (long2ip(ip2long($ip)) == $ip);
        }
        
        function is_valid_date($d, $m, $y) {
        	return (checkdate($m, $d, $y));
        }
    	
    }

?>